from typing import List


class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        length = len(nums)
        i = 0
        j = 1
        while i < length:
            while j < length and nums[j] <= nums[i]:
                j += 1
            if j == length:
                break
            nums[i+1] = nums[j]
            i += 1
        return i + 1


if __name__ == "__main__":
    nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4]
    print(Solution().removeDuplicates(nums))
    print(nums)
    pass
